// 文章相关的请求模块

import requset from '@/utils/request'

// 获取文章列表
export const getArticles = params => {
    return requset({
        method: 'GET',
        url: '/app/v1_1/articles',
        params
    })
}

// 获取文章详情
export const getArticleDetail = articleId => {
    return requset({
        method: 'GET',
        url: `/app/v1_0/articles/${articleId}`
    })
}

// 关注用户
export const addFollow = authorId => {
    return requset({
        method: 'post',
        url: '/app/v1_0/user/followings',
        data: {
            target: authorId
        }
    })
}

// 取消关注用户
export const deleteFollow = authorId => {
    return requset({
        method: 'DELETE',
        url: `/app/v1_0/user/followings/${authorId}`
    })
}

// 收藏文章
export const addCollect = articleId => {
    return requset({
        method: 'POST',
        url: '/app/v1_0/article/collections',
        data: {
            target: articleId
        }
    })
}

// 取消收藏文章
export const deleteCollect = articleId => {
    return requset({
        method: 'DELETE',
        url: `/app/v1_0/article/collections/${articleId}`
    })
}

// 对文章点赞
export const addLike = articleId => {
    return requset({
        method: 'POST',
        url: '/app/v1_0/article/likings',
        data: {
            target: articleId
        }
    })
}

// 取消对文章点赞
export const deleteLike = articleId => {
    return requset({
        method: 'DELETE',
        url: `/app/v1_0/article/likings/${articleId}`
    })
}
